package com.gzhryc.dictionary.dao.db;

import com.gzhryc.dictionary.dao.enums.ConfigInfoEnum;
import com.gzhryc.jdbc.annotaion.Column;
import com.gzhryc.jdbc.annotaion.PrimaryKey;
import com.gzhryc.jdbc.annotaion.Table;

import java.util.Date;

@Table(name = "dic_config_info")
public class ConfigInfo {

	@PrimaryKey
	@Column(length = 32, notNull = true, note = "参数名称")
	private String name;

	@PrimaryKey
	@Column(name = "type", notNull = true, note = "配置类型")
	private Integer type;

	@Column(name = "data_type", notNull = true, note = "数据类型")
	private Integer dataType;

	@Column(name = "string_value", type="TEXT", note = "字符串类型")
	private String stringValue;

	@Column(name = "long_value", note = "长整型数据")
	private Long longValue;

	@Column(name = "integer_value", note = "整型数据")
	private Integer integerValue;

	@Column(name = "double_value", note = "浮点型数据")
	private Double doubleValue;

	@Column(name = "date_value", note = "时间数据")
	private Date dateValue;

	@Column(name = "boolean_value", note = "布尔类型数据")
	private Boolean booleanValue;

	@Column(name = "update_date", autoUpdateTime = true)
	protected Date updateDate;

	@Column(name = "create_date")
	protected Date createDate;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getDataType() {
		return dataType;
	}

	public void setDataType(Integer dataType) {
		this.dataType = dataType;
	}

	public String getStringValue() {
		return stringValue;
	}

	public void setStringValue(String stringValue) {
		this.stringValue = stringValue;
	}

	public Long getLongValue() {
		return longValue;
	}

	public void setLongValue(Long longValue) {
		this.longValue = longValue;
	}

	public Integer getIntegerValue() {
		return integerValue;
	}

	public void setIntegerValue(Integer integerValue) {
		this.integerValue = integerValue;
	}

	public Double getDoubleValue() {
		return doubleValue;
	}

	public void setDoubleValue(Double doubleValue) {
		this.doubleValue = doubleValue;
	}

	public Date getDateValue() {
		return dateValue;
	}

	public void setDateValue(Date dateValue) {
		this.dateValue = dateValue;
	}

	public Boolean getBooleanValue() {
		return booleanValue;
	}

	public void setBooleanValue(Boolean booleanValue) {
		this.booleanValue = booleanValue;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Object getValue() {
		if(ConfigInfoEnum.DataType.StringType.index().equals(this.dataType)) {
			return this.stringValue;
		}else if(ConfigInfoEnum.DataType.IntegerType.index().equals(this.dataType)) {
			return this.integerValue;
		}else if(ConfigInfoEnum.DataType.LongType.index().equals(this.dataType)) {
			return this.longValue;
		}else if(ConfigInfoEnum.DataType.DoubleType.index().equals(this.dataType)) {
			return this.doubleValue;
		}else if(ConfigInfoEnum.DataType.DateType.index().equals(this.dataType)) {
			return this.dateValue;
		}else if(ConfigInfoEnum.DataType.BooleanType.index().equals(this.dataType)) {
			return this.booleanValue;
		}
		return null;
	}
}
